package eu.tsp.isensors.communication.api;

import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Component;

import eu.tsp.isensors.services.storage.Get;
import eu.tsp.isensors.services.storage.Put;

@Component(immediate=true, factoryMethod="getInstance")
public class ServicesInvoke{
	
   static ServicesInvoke instance = null;

   @Requires
   public Put m_put; // Service Dependency
   
   @Requires
   public Get m_get; // Service Dependency

/*
   public void invokeHelloServices() {
      for (int i = 0; i < m_hello.length; i++) {
          // Update with your name.
          System.out.println(m_hello[i].sayHello("wassim"));
      }
   }
*/

   public byte[] invokeGetBytes(String str){
	return m_get.get(str);
   }
  
   public String invokeGetString(String str){
        return m_get.get_as_string(str);
   }

   public String invokePut(String collection, String mimeType, byte[] data, String name){
	return  m_put.put(collection, mimeType, data, name);
   }

   protected ServicesInvoke() {
      // Exists only to defeat instantiation.
   }
   public static ServicesInvoke getInstance() {
      if(instance == null) {
         instance = new ServicesInvoke();
      }
      return instance;
   }
}
